import Vue from 'vue'
import Router from 'vue-router'
// 封装懒加载
const lazy = url => () => import('@/views/' + url)

Vue.use(Router)

export default new Router({
  mode: 'history',
  base: process.env.BASE_URL,
  linkActiveClass: 'cube-tab_active',
  routes: [
    { path: '/', redirect: '/index' },
    { path: '/index', component: lazy('index.vue') },
    { path: '/vip', component: lazy('vip.vue') },
    { path: '/cart', component: lazy('cart.vue') },
    { path: '/search', component: lazy('search.vue') },
    // 新闻
    { path: '/index/news', component: lazy('index/news.vue') },
    { path: '/index/news/:id', component: lazy('index/article.vue') },
    // 图片
    { path: '/index/picture', component: lazy('index/picture.vue') },
    // 商品
    { path: '/index/goods', component: lazy('index/goods.vue') },
    { path: '/index/goods/:id', component: lazy('index/goodsinfo.vue') },
    { path: '/index/goods/:id/intro', component: lazy('index/goodsintro.vue'), name: 'goodsintro' },
    { path: '/index/goods/:id/comment', component: lazy('index/goodscom.vue'), name: 'goodscom' }
  ]
})
